﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace HeightControlAssistanceProgram.ConvertHelper
{
    /// <summary>
    /// 电梯按钮自动绑定，如果是顶层，就没有向上按钮；如果是最低层，就没有向下按钮。
    /// </summary>
    class Visibility_For_Button_Up_Down_ConvertHelper : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Visibility result = Visibility.Visible;
            if (value is BaseHeightControl.Floor floor)
            {
                
                if (floor.IsTopOrBottom == BaseHeightControl.FloorLevel.Middle)
                {
                    result = Visibility.Visible;
                }
                else
                {
                    switch (parameter)
                    {
                        case "Up":
                            {
                                if (floor.IsTopOrBottom == BaseHeightControl.FloorLevel.Top)
                                {
                                    result = Visibility.Collapsed;
                                }
                            }
                            break;
                        case "Down":
                            {
                                if (floor.IsTopOrBottom == BaseHeightControl.FloorLevel.Bottom)
                                {
                                    result = Visibility.Collapsed;
                                }
                            }
                            break;
                        default:
                            result = Visibility.Visible;
                            break;
                    }
                }
            }
            return result;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
